package com.example.matchapp;

import com.alibaba.fastjson.JSON;
import pojo.admin;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;

@WebServlet(name = "jsonTestServlet", value = "/jsonTest")
public class jsonTestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("application/json; charset=utf-8");
        response.setCharacterEncoding("UTF-8");
        admin a = new admin("105518821","EErk","1145141919810");
        // 调用接口
        String userJson = JSON.toJSONString(a);
        OutputStream out = response.getOutputStream();
        out.write(userJson.getBytes("UTF-8"));
        out.flush();
    }

    public void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
